package com.md.yleducationsupervisor

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import com.md.adapter.ChildAdapter
import com.md.adapter.JiLuAdapter
import com.md.adapter.TeacherAdapter
import com.md.base.BaseActivity
import com.md.nohttp.Params
import com.scwang.smartrefresh.layout.api.RefreshLayout
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener
import kotlinx.android.synthetic.main.layout_list.*

class ChildListActivity : BaseActivity() {

    private var adapter: ChildAdapter? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_child_list)
        changeTitle("学生列表")
        init()
    }

    fun init() {
        linearLayoutManager = LinearLayoutManager(baseContext)
        recycle_list.layoutManager = linearLayoutManager
        recycle_list.isNestedScrollingEnabled = false//禁止滑动
        adapter = ChildAdapter(baseContext, R.layout.item_child, Params.datas)
        recycle_list.adapter = adapter
        smart.setOnLoadMoreListener {
            object : OnRefreshLoadMoreListener {
                override fun onLoadMore(refreshLayout: RefreshLayout) {
                    smart.finishLoadMore()
                }

                override fun onRefresh(refreshLayout: RefreshLayout) {
                    smart.finishRefresh()
                }
            }
        }
    }
}
